import requests
from enum import Enum

class Method(Enum):
    GET = 'GET'
    POST = 'POST'

def http_request(method, url, json=None, **kwargs):
    response = requests.request(method.value, url, json=json, **kwargs)
    try:
        return response.json()
    except ValueError:
        return {'error': f'Invalid JSON response: {response.text}'}
